From: Brion Vibber Date: Sat, 24 Sep 2005 06:38:36 +0000 (+0000) Subject: * Add options to dumpBackup.php for making split/partial dumps by page id X-Git-Tag: 1.6.0~1585 X-Git-Url: http://git.cyclocoop.org/%28%5B%5E/404?a=commitdiff_plain;h=99967490f97370113bc1c292738644759622f4c1;p=lhc%2Fweb%2Fwiklou.git * Add options to dumpBackup.php for making split/partial dumps by page id --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index c59eddb2d7..ae8b513cf1 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -119,6 +119,7 @@ fully support the editing toolbar, but was found to be too confusing. * Skip update of disused 'rc_cur_time' field (todo: discard the field) * (bug 3506) Avoid MySQL error when Listusers returns no results * (bug 3182) Clear link cache during import to prevent memory leak +* Add options to dumpBackup.php for making split/partial dumps by page id === Caveats === diff --git a/includes/SpecialExport.php b/includes/SpecialExport.php index 8de0f184fc..861addcc6c 100644 --- a/includes/SpecialExport.php +++ b/includes/SpecialExport.php @@ -214,14 +214,26 @@ class WikiExporter { * Dumps a series of page and revision records for all pages * in the database, either including complete history or only * the most recent version. - * - * - * @param Database $db */ function allPages() { return $this->dumpFrom( '' ); } + /** + * Dumps a series of page and revision records for those pages + * in the database falling within the page_id range given. + * @param int $start Inclusive lower limit (this id is included) + * @param int $end Exclusive upper limit (this id is not included) + * If 0, no upper limit. + */ + function pagesByRange( $start, $end ) { + $condition = 'page_id >= ' . intval( $start ); + if( $end ) { + $condition .= ' AND page_id < ' . intval( $end ); + } + return $this->dumpFrom( $condition ); + } + /** * @param Title $title */ diff --git a/maintenance/dumpBackup.php b/maintenance/dumpBackup.php index a15fbf2116..c5b05b9bc6 100644 --- a/maintenance/dumpBackup.php +++ b/maintenance/dumpBackup.php @@ -24,7 +24,7 @@ $originalDir = getcwd(); -$optionsWithArgs = array( 'server', 'pagelist' ); +$optionsWithArgs = array( 'server', 'pagelist', 'start', 'end' ); require_once( 'commandLine.inc' ); require_once( 'SpecialExport.php' ); @@ -36,6 +36,10 @@ class BackupDumper { var $revCount = 0; var $server = null; // use default var $pages = null; // all pages + var $skipHeader = false; // don't output and + var $skipFooter = false; // don't output + var $startId = 0; + var $endId = 0; function BackupDumper() { $this->stderr = fopen( "php://stderr", "wt" ); @@ -60,15 +64,21 @@ class BackupDumper { $exporter->setPageCallback( array( &$this, 'reportPage' ) ); $exporter->setRevisionCallback( array( &$this, 'revCount' ) ); - $exporter->openStream(); + if( !$this->skipHeader ) + $exporter->openStream(); - if ( is_null( $this->pages ) ) { - $exporter->allPages(); + if( is_null( $this->pages ) ) { + if( $this->startId || $this->endId ) { + $exporter->pagesByRange( $this->startId, $this->endId ); + } else { + $exporter->allPages(); + } } else { $exporter->pagesByName( $this->pages ); } - $exporter->closeStream(); + if( !$this->skipFooter ) + $exporter->closeStream(); $this->report( true ); } @@ -154,6 +164,15 @@ if ( isset( $options['pagelist'] ) ) { $dumper->pages = array_filter( $pages, create_function( '$x', 'return $x !== "";' ) ); } +if( isset( $options['start'] ) ) { + $dumper->startId = intval( $options['start'] ); +} +if( isset( $options['end'] ) ) { + $dumper->endId = intval( $options['end'] ); +} +$dumper->skipHeader = isset( $options['skip-header'] ); +$dumper->skipFooter = isset( $options['skip-footer'] ); + if( isset( $options['full'] ) ) { $dumper->dump( MW_EXPORT_FULL ); } elseif( isset( $options['current'] ) ) { @@ -169,10 +188,16 @@ Usage: php dumpBackup.php [] Actions: --full Dump complete history of every page. --current Includes only the latest revision of each page. + Options: --quiet Don't dump status reports to stderr. --report=n Report position and speed after every n pages processed. (Default: 100) + --server=h Force reading from MySQL server h + --start=n Start from page_id n + --end=n Stop before page_id n (exclusive) + --skip-header Don't output the header + --skip-footer Don't output the footer END ); }